import FTGL
import os

from logger                  import log

class Fonts(object):
    def __init__(self):
        self.fontRef = {}
        self.uiFonts = []
        
    def __call__(self, fontfilename, fonttype, size):
        f = self.fontRef.get((fontfilename, fonttype, size), None)
        if f:
            return f
        try:
            assert os.path.isfile(fontfilename)
        except:
            log.error('Font file path not correct. Failed to load fonts')
            return None
        
        f = fonttype(fontfilename)
        f.FaceSize(size)
        self.fontRef[(fontfilename, fonttype, size)] = f
        self.uiFonts.append(f)
        return f
        
        
fonts = Fonts()


regularFont = fonts('Courier_New.ttf', FTGL.TextureFont, 14)
tooltipFont = fonts('Verdana.ttf', FTGL.TextureFont, 14)

assert isinstance(tooltipFont, FTGL.TextureFont)
assert isinstance(regularFont, FTGL.TextureFont)
fontData = []
